//
//  HYLPageScroll.m
//  UIScrollView测试
//
//  Created by hyl on 16/5/2.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "HYLPageScroll.h"

@interface HYLPageScroll ()
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;

@property (weak, nonatomic) IBOutlet UIScrollView *pageScroll;

@end

@implementation HYLPageScroll
+(instancetype)pageScroll{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil]firstObject];
}
-(void)setPictures:(NSArray *)pictures{
    _pictures=pictures;
    for (int i=0; i<pictures.count; i++) {
        UIImageView *imageView=[[UIImageView alloc]init];
        imageView.image=[UIImage imageNamed:pictures[i]];
        [self.pageScroll addSubview:imageView];
    }
    self.pageScroll.contentSize=CGSizeMake(pictures.count*300, 0);
    self.pageScroll.pagingEnabled=YES;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    for (int i=0; i<self.pageScroll.subviews.count; i++) {
        self.pageScroll.subviews[i].frame=CGRectMake(i*300, 0, 300, 130);
    }
}
@end
